// -----------------------------
// Author: 		Dhaenens Gert	
// Creation: 	8/2/2013 7:33:39 PM				
// -----------------------------

#include "LuaException.h"
#include <string>

namespace ObjectLua
{

	LuaException::LuaException(const char* lpMsg)
		: m_lpMessage(nullptr)
	{
		size_t strLen = strlen(lpMsg) + 1;
		m_lpMessage = new char[strLen];
		strcpy_s(m_lpMessage,strLen,lpMsg);
	}

	LuaException::LuaException(const LuaException& refLuaException)
		: m_lpMessage(nullptr)
	{
		size_t strLen = strlen(refLuaException.m_lpMessage);
		m_lpMessage = new char[strLen];
		strcpy_s(m_lpMessage,strLen,refLuaException.m_lpMessage);
	}

	LuaException& LuaException::operator=(const LuaException& refLuaException)
	{
		size_t strLen = strlen(refLuaException.m_lpMessage);
		m_lpMessage = new char[strLen];
		strcpy_s(m_lpMessage,strLen,refLuaException.m_lpMessage);
		return (*this);
	}
	
	LuaException::~LuaException()
	{
		if(m_lpMessage)
			delete[] m_lpMessage;
	}

	const char* LuaException::message() const
	{
		return m_lpMessage;
	}

}